<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" 
      xmlns:f="http://java.sun.com/jsf/core" 
      xmlns:h="http://java.sun.com/jsf/html" 
      xmlns:p="http://primefaces.prime.com.tr/ui"
      xmlns:ezcomp="http://java.sun.com/jsf/composite/ezcomp"> 
    <h:head>
        <title>Stakeholder Rewards Manager</title>
        
        <link rel="stylesheet" type="text/css" href="CSS/RandallCSS.css" />
        <style type="text/css"> 

            .gritter-notice-wrapper { 
                left:200px; 
                top:50px; 
            } 
        </style> 
    </h:head>
    
    
    
    <h:body>
        <h1>Stakeholder Account and Billing Management -- Rewards Management</h1> 

        <p:layout style="table-layout:auto; height:700px ">
            <p:layoutUnit position="left" header="Navigation" width="300">
                <ezcomp:RepSABMLeftMenu/>
            </p:layoutUnit>
            
            
            
            <p:layoutUnit position="center" header="Settings" scrollable="true">
                            <b>Current Rewards</b><br/>
                            <div class ="contentbox">
                                        <h:form>
                                                <br/>
                                                <br/>
                                                <p:dataTable value="#{rewardMB.getStakeholderItems()}" var="o"
                                                     styleClass="order-table-shoppingcart"
                                                     rowStyleClass="contentbox"
                                                     emptyMessage="You have no rewards created"
                                                     >
                                                        
                                                    

                                                    <p:column style="width: 10px">
                                                        <f:facet name="header">ID</f:facet>
                                                        #{o.id}
                                                    </p:column>

                                                    <p:column style="width: 50px">
                                                        <f:facet name="header">Name</f:facet>
                                                        #{o.reward_Name}
                                                    </p:column>

                                                    <p:column style="width: 80px">
                                                        <f:facet name="header">Description</f:facet>
                                                        <h:outputText value="#{o.reward_Description}" escape="false"/>
                                                        
                                                    </p:column>

                                                    <p:column style="width: 40px">
                                                        <f:facet name="header">Points Cost</f:facet>
                                                        #{o.reward_Cost}
                                                    </p:column>

                                                    <p:column style="width: 40px">
                                                        <f:facet name="header">Vouchers Left</f:facet>
                                                        #{o.getRemainingVouchers()}
                                                    </p:column>
                                                    

                                                    <p:column style="width: 50px">                    
                                                        <p:commandButton value="Remove" action="#{rewardMB.deleteReward(o)}" ajax="false"/>
                                                    </p:column>


                                                </p:dataTable>

                                        </h:form>   
                                </div>



                            <br/>
                            <br/>
                            <br/>
                            <b>Add new Reward Item</b><br/>
                            <h:form>                   
                                <h:panelGrid columns="3">
        
                                        <h:outputLabel for="rewardName" value="Reward name:"/>
                                        <p:inputText required="true" requiredMessage="Reward name is requied!"
                                             id="rewardName" value="#{rewardMB.reward_Name}"/>
                                        <p:message for="rewardName"/>


                                        <h:outputLabel for="rewardDesc" value="Reward description"/>
                                        <p:inputTextarea required="true" requiredMessage="Reward description is requied!"
                                             id="rewardDesc" value="#{rewardMB.reward_Description}"/>
                                        <p:message for="rewardDesc"/>


                                        <h:outputLabel for="rewardCost" value="Reward cost"/>
                                        <p:inputText required="true" requiredMessage="Reward cost is requied!"
                                             id="rewardCost" value="#{rewardMB.reward_Cost}"/>
                                        <p:message for="rewardCost"/>         


                                        <h:outputLabel for="numVouchers" value="Vouchers Amount"/>
                                        <p:inputText id="numVouchers" value="#{rewardMB.vouchers_left}" required="true">
                                                <f:validateLongRange minimum="1"/> 
                                        </p:inputText>
                                        <p:message for="numVouchers"/>    
                                 </h:panelGrid>
                                    <h:outputLabel value="Unlimited Vouchers"/>
                                    <h:selectBooleanCheckbox value="#{rewardMB.unlimitedVouchers}"/>
                                
                                <br/>
                                NOTE: If unlimited vouchers is checked, the system will ignore the Vouchers Amount input.
                                <br/>
                                <br/>
                                <h:commandButton action="#{rewardMB.createReward()}" value="Create Reward Item"/>
                            </h:form>       
                            
                            
                            
            </p:layoutUnit>
            
        </p:layout>
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
    </h:body>
</html>

